public class Main {
    private static String userName = "admin";
    private static String password = "123456";

    public static void main(String[] args) {
        try {
            login("admin", "12456");
        } catch (UserError userError) {
            System.out.println("用户名异常");
        } catch (PasswordError passwordError) {
            System.out.println("密码异常");

        }
    }
    public static void login(String userName, String password) throws UserError,PasswordError {
        if (!Main.userName.equals(userName)) {
            throw new UserError("用户名错误");
        }
        if (!Main.password.equals(password)) {
            throw new PasswordError("密码错误");
        }
        System.out.println("登陆成功");
    }
}
class UserError extends Exception {
    public UserError(String message) {
        super(message);
    }
}
class PasswordError extends Exception {
    public PasswordError(String message) {
        super(message);
    }
}